***********************************************************
*  REPLICATION DATA for VOTING BETWEEN TWO GLOBAL CRISIS  *
*                                                         *
*                      Marco GIULIANI                     *
***********************************************************

use "C:\your folder\Voting SE - Time series.dta"

xtset ncountry Year

*** Figure 1

twoway (tsline Natemp, lcolor(navy) lpattern(solid)) (tsline Maxemp, lcolor(navy) lpattern(longdash)) (tsline Minemp, lcolor(navy) lpattern(dash)), ylabel(20(20)80, labsize(small)) ttitle(, color(none)) tscale(range(2010 2020)) tlabel(#6, labsize(small)) by(, title(Employment rate, size(medium)) note(, color(none) fcolor(none))) by(, legend(off)) by(, clegend(off)) by(, graphregion(fcolor(white))) by(country) subtitle(, nobox)

twoway (tsline Natfor, lcolor(red) lpattern(solid)) (tsline Maxfor, lcolor(red) lpattern(longdash)) (tsline Minfor, lcolor(red) lpattern(dash)), yline(0, lwidth(thin) lcolor(gs11)) ylabel(0(5)20, labsize(small)) ttitle(, color(none)) tscale(range(2010 2020)) tlabel(#6, labsize(small)) by(, title(Pct foreign population, size(medium)) note(, color(none) fcolor(none))) by(, legend(off)) by(, clegend(off)) by(, graphregion(fcolor(white))) by(country) subtitle(, nobox)


*** Figure A.1

twoway (tsline Natchangefor, lcolor(midgreen) lpattern(solid)) (tsline Maxchangefor, lcolor(midgreen) lpattern(longdash)) (tsline Minchangefor, lcolor(midgreen) lpattern(dash)), yline(0, lwidth(thin) lcolor(gs11)) ylabel(-4(2)4, labsize(small)) ttitle(, color(none)) tscale(range(2010 2020)) tlabel(#6, labsize(small)) by(, title(Change in pct foreign population, size(medium)) note(, color(none) fcolor(none))) by(, legend(off)) by(, clegend(off)) by(, graphregion(fcolor(white))) by(country) subtitle(, nobox)



use "C:\your folder\Voting SE - Nuts3 dataset.dta"

*** Table 1 & Figure 2

mixed incumbent lagincumbent emprate growth coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry

mixed incumbent lagincumbent emprate growth deltafor coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry

mixed incumbent lagincumbent emprate growth c.deltafor##c.leftgov coalition deltaturnout density over65  ||_all:R.election ||_all:R.ncountry
margins, dydx(deltafor) at(leftgov=(0(1)100)) vsquish
marginsplot, recast (line) recastci(rline) ciopts(lpattern(dash)) yline(0, lcolor(red)) ytitle("Marginal effect of Change in foreign population", size(medsmall) axis(1)) ylabel(,labsize(medsmall)) title("") legend(off) scheme(s2mono) graphregion(fcolor(white)) xsca(titlegap(2)) xtitle(Pct left parties in government) xlabel(,labsize(medsmall))

***Table A.7 & Figure 3
mixed incumbent lagincumbent c.emprate##c.deltafor growth coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry

mixed incumbent lagincumbent c.emprate##c.deltafor growth coalition deltaturnout density over65 if leftgov<50 ||_all:R.election ||_all:R.ncountry
margins, dydx(deltafor) at(emprate=(30.5(0.5)79)) vsquish
marginsplot, recast (line) recastci(rline) ciopts(lpattern(dash)) legend(off) scheme(s2mono) graphregion(fcolor(white)) xsca(titlegap(2)) addplot(hist emprate if leftgov<50, percent yaxis(2) bin(20) lwidth(vvthin) color(none) lcolor(gs10) yscale(alt axis(2))) yline(0, lcolor(red)) ytitle("Marginal effect of Change in foreign population", axis(1)) ylabel(,labsize(medsmall)) title("") xtitle(Employment rate) title("Centre-right cabinets") xlabel(,labsize(medsmall))

mixed incumbent lagincumbent c.emprate##c.deltafor growth coalition deltaturnout density over65 if leftgov>50 ||_all:R.election ||_all:R.ncountry
margins, dydx(deltafor) at(emprate=(30.5(0.5)79)) vsquish
marginsplot, recast (line) recastci(rline) ciopts(lpattern(dash)) legend(off) scheme(s2mono) graphregion(fcolor(white)) xsca(titlegap(2)) addplot(hist emprate  if leftgov>50, percent yaxis(2) bin(20) lwidth(vvthin) color(none) lcolor(gs10) yscale(alt axis(2))) yline(0, lcolor(red)) ytitle("Marginal effect of Change in foreign population", axis(1)) ylabel(,labsize(medsmall)) title("") xtitle(Employment rate) title("Centre-left cabinets") xlabel(,labsize(medsmall))



***** In the Appendix

*** Table A.6 Empty crossclassified model
mixed incumbent  ||_all:R.election ||_all:R.ncountry



*** Robustness replications of model 3 with different measures of government composition or type of interaction (Fig. A.2)

* Curvilinear interaction (squared leftgov)
mixed incumbent lagincumbent emprate growth c.deltafor##c.leftgov##c.leftgov coalition deltaturnout density over65  ||_all:R.election ||_all:R.ncountry
margins, dydx(deltafor) at(leftgov=(0(1)100)) vsquish
marginsplot, recast (line) recastci(rline) ciopts(lpattern(dash)) yline(0, lcolor(red)) ytitle("Marginal effect of Change in foreign population", axis(1)) title("") legend(off) scheme(s2mono) graphregion(fcolor(white)) xsca(titlegap(2)) xtitle(Pct left parties in government)

* Classification with 5 government categories (gov_party in Armingeon,Engler, Leeman 2021)
mixed incumbent lagincumbent emprate growth c.deltafor##i.govparty coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry
margins, dydx(deltafor) at(govparty =(1(1)4)) vsquish
marginsplot, scheme(s2mono) graphregion(fcolor(white)) yline(0, lcolor(red)) ytitle("Marginal effect of Change in foreign population") xtitle("") xlabel(,labsize(small)) title("")

*Classification with 3 government categories (recoded from previous gov_party)
mixed incumbent lagincumbent emprate growth c.deltafor##i.govparty2 coalition deltaturnout density over65  ||_all:R.election ||_all:R.ncountry
margins, dydx(deltafor) at(govparty2 =(1(1)3)) vsquish
marginsplot, scheme(s2mono) graphregion(fcolor(white)) yline(0, lcolor(red)) ytitle("Marginal Effect of Change in foreign population") xtitle("") xlabel(,labsize(small)) title("")



*** Robustness replications using unemployment and level of foreign population 

** Table A.8

mixed incumbent lagincumbent unemp growth deltafor coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry

mixed incumbent lagincumbent emprate growth for coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry

mixed incumbent lagincumbent unemp growth for coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry

** Figure A.3

mixed incumbent lagincumbent emprate growth c.for##c.leftgov coalition deltaturnout density over65  ||_all:R.election ||_all:R.ncountry
margins, dydx(for) at(leftgov=(0(1)100)) vsquish
marginsplot, recast (line) recastci(rline) ciopts(lpattern(dash)) yline(0, lcolor(red)) ytitle("Marginal Effect of Foreign population", axis(1)) title("") legend(off) scheme(s2mono) graphregion(fcolor(white)) xsca(titlegap(2)) xtitle(Pct left parties in government)

mixed incumbent lagincumbent emprate growth c.for##c.leftgov##c.leftgov coalition deltaturnout density over65  ||_all:R.election ||_all:R.ncountry
margins, dydx(for) at(leftgov=(0(1)100)) vsquish
marginsplot, recast (line) recastci(rline) ciopts(lpattern(dash)) yline(0, lcolor(red)) ytitle("Marginal effect of Foreign population", axis(1)) title("") legend(off) scheme(s2mono) graphregion(fcolor(white)) xsca(titlegap(2)) xtitle(Pct left parties in government)

mixed incumbent lagincumbent emprate growth c.for##i.govparty coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry
margins, dydx(for) at(govparty =(1(1)4)) vsquish
marginsplot, scheme(s2mono) graphregion(fcolor(white)) yline(0, lcolor(red)) ytitle("Marginal effect of Foreign population") 

mixed incumbent lagincumbent emprate growth c.for##i.govparty2 coalition deltaturnout density over65  ||_all:R.election ||_all:R.ncountry
margins, dydx(for) at(govparty2 =(1(1)3)) vsquish
marginsplot, scheme(s2mono) graphregion(fcolor(white)) yline(0, lcolor(red)) ytitle("Marginal effect of Foreign population") 



*** Robustness replications using only the leading party votes (Table A.9)

mixed lead laglead emprate growth deltafor coalition deltaturnout density over65 ||_all:R.election ||_all:R.ncountry



